<?php
namespace Swoole\Socket;
use Swoole\Socket\IServer;
use Common\Log;
class SocketServer{  // implements IServer
    private $serv;
    private $iServer;
    private $host;
    private $port;
//     private $set;
    function __construct($iServer, $host, $port, $set){
        Log::info("SocketServer __construct $host:$port");
        $this->host = $host;
        $this->port = $port;
        $this->iServer = $iServer;
        $this->set = $set;


    }
    function start(){
        $this->serv = new \swoole_server($this->host, $this->port);
        $this->serv->on('Start', array($this->iServer, 'onStart'));
//         $this->serv->on('Shutdown', array($this->iServer, 'onShutdown'));
        $this->serv->on('Connect', array($this->iServer, 'onConnect'));
        $this->serv->on('Receive', array($this->iServer, 'onReceive'));
        $this->serv->on('Close', array($this->iServer, 'onClose'));
        $this->serv->set($this->set);
        $this->serv->start();
    }
}

?>